/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package wap.rockvilletech.util.imaging;

import org.apache.log4j.Logger;

/**
 * 
 * @author Bilal
 */
public class Inputvalidation {

	private static final Logger log = Logger.getLogger(Inputvalidation.class);

	public Inputvalidation() {
	}// end constructor

	public long isNumaric(String id) {
		long intVal = 0;
		try {
			intVal = Long.parseLong(id);

		} catch (Exception e) {
			log.error("isNumaric", e);
			return -1;
		}
		return intVal;

	}// end

	public String validateMSISDN(String uGsm) {
		String strGsm = "";

		if (isNumaric(uGsm) == (long) -1) {
			return "INVALID";
		}

		try {
			// System.out.println("UGsm length " + uGsm.length());
			if (uGsm.startsWith("92") && uGsm.length() == 12) {
				strGsm = uGsm.toString();
				// System.out.println("Its valid Ugsm no");
			} else if (uGsm.startsWith("03") && uGsm.length() == 11) {
				// System.out.println("Its start with 03");
				uGsm = uGsm.replaceFirst("0", "92");
				// System.out.println("GSM Replacement"+ uGsm);
				strGsm = uGsm.toString();
			} else if (uGsm.startsWith("3") && uGsm.length() == 10) {
				// System.out.println("Its start with 03");
				uGsm = uGsm.replaceFirst("3", "923");
				// System.out.println("GSM Replacement"+ uGsm);
				strGsm = uGsm.toString();
			} else {
				strGsm = "INVALID";
			}
		} catch (Exception e) {
			log.error("validateMSISDN", e);
		}
		return strGsm;
	}// end valid Gsm
}
